<template>
    <div class="container">
        <div class='u-title f-mtp10'>
            <h2>提现设置</h2>
        </div>

        <div class='u-content mn flex flex-column flex-center'>
            <div class='item'>
                <label for="">提现最小额（元）：</label>
                <div class='item-right f-w300 '>
                    <el-input class='f-w300' v-model="minWithdrawAmount" placeholder="1000"></el-input>
                    <p class='tip'>账户低于此金额将无法提现</p>
                </div>
            </div>
            <div class='item'>
                <label for="">提现佣金设置：</label>
                <div class='item-right f-w300 '>
                    <el-input class='f-w300 f-mbt20' placeholder="00%" v-model="userFee">
                        <template slot="append">用户提现</template>
                    </el-input>
                    <div></div>
                    <el-input class='f-w300' placeholder="00%" v-model="lawyerFee" >
                        <template slot="append">律师提现</template>
                    </el-input>
                    <p class='tip'>提现时将扣除相应佣金</p>
                </div>
            </div>
            <div class='btn-box f-ptp20'>
                <el-button
                    class='f-w300 s-bg-green s-cfff'
                    @click="submit">提交</el-button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
  name: 'WithdrawCashSetting',
  data() {
    return {
      radio: '1',
      minWithdrawAmount: '',
      lawyerFee:'',
      currentSetting:{},
      userFee: ''
      }
  },
  computed: {
  
  },
  created: function() {
    this.getWithdrawCase();
  },
  methods: {
    // 
    submit() {
      this.updateWithdrawCase();  
    },  
    // 添加员工 
    updateWithdrawCase() {
        this.$store.dispatch('SET_WITHDRAW', {
            minWithdrawAmount: this.minWithdrawAmount,
            userFee: this.userFee,
            lawyerFee: this.lawyerFee
        }).then(res => {
            if(res.data.retCode == 0) {
                this.$message.success('设置成功！');
                this.$router.push('/home/withdrawCash');
            }
        }).catch(err => {
            console.error('新增招标：：', err)
        })
    }, 
    // 获取部门列表  
    getWithdrawCase() {

        this.$store.dispatch('GET_WITHDRAW_SETTING', null).then(res => {
            if(res.data.retCode == 0) {
                this.totalCount = res.data.data.totalCount;
                this.lawyerFee=res.data.data.lawyerFee;
                this.minWithdrawAmount=res.data.data.minWithdrawAmount;
                this.userFee=res.data.data.userFee;
            }
        }).catch(err => {
            console.error('获取问题列表：：', err);
        })
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.radio-box{
  line-height: 40px;
}
.container{
  width: 800px;
  /* margin: 0 auto; */
}
.mn{
    padding: 30px 0 50px 0;
}
.item{
    display: flex;
    margin-bottom: 10px;
}
.item>label{
    display: inline-block;
    width: 130px;
    line-height: 40px;
    text-align: right;
    margin-right: 10px;
}
/* .item>label::before{
    content: '*';
    line-height: 40px;
    color: red;
    margin-right: 5px;
} */
.item-right{
    /* width: 600px */
}
.btn-box{
    padding-left: 130px;
}
.tip{
    font-size: 12px;
    color: #999;
    margin-bottom: 10px;
    margin-top: 10px;
    /* line-height: 24px; */
}
</style>
